﻿<div style="background:#fbf9fe" ms-controller="MGZBG">
    <div ms-if="isHasDataQX=='Y'">
        <!--<div class="weui_cells_title">基本信息</div>-->
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">报告类型</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <select ms-duplex="modelData.LeiBie" class="weui-select szhl szhl_require">
                        <option ms-repeat-item="ColumnData" ms-attr-value="item.ID" ms-attr-selected="item.ID==modelData.LeiBie?'selected':''">{{item.TypeName}}</option>
                    </select>
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">报告时间</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input type="text" placeholder="请选择时间" id="appDate" ms-duplex="modelData.RBDate" class="weui_input szhl szhl_require" />
                </div>
            </div>
            <div class="weui_cells_form">
                <div class="weui_cell">
                    <div class="weui_cell_hd" style="display:none;"><label class="weui_label label">报告内容</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <textarea ms-duplex="modelData.RBContent" rows="3" placeholder="请输入报告内容" class="weui_textarea szhl szhl_require" style="height:180px;"></textarea>
                    </div>
                </div>
            </div>
        </div>
        <div class="weui_cells_title">其他信息</div>
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_hd" style="display:none;"><label class="weui_label label">完成情况</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <textarea class="weui_textarea" ms-duplex="modelData.RBWCQK" rows="3" placeholder="请输入完成情况"></textarea>
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">抄送人</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input type="text" id="conCSR" placeholder="请选择抄送人" ms-duplex="modelData.ChaoSongUser" class="weui_input szhl szhl_getPeoples" />
                </div>
            </div>
        </div>
        <div class="weui_cells_title">图片上传</div>
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <input type="text" id="upFile" class="wximgupload" style="display:none" ms-duplex="modelData.Files" />
                </div>
            </div>
        </div>
    </div>
    <div ms-if="isHasDataQX=='N'">
        <!--<div class="weui_cells_title">基本信息</div>-->
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">报告类型</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <select ms-duplex="modelData.LeiBie" class="weui-select szhl szhl_require">
                        <option ms-repeat-item="ColumnData" ms-attr-value="item.ID" ms-attr-selected="item.ID==modelData.LeiBie?'selected':''">{{item.TypeName}}</option>
                    </select>
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">报告时间</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    {{modelData.RBDate}}
                </div>
            </div>
            <div class="weui_cells_form">
                <div class="weui_cell">
                    <div class="weui_cell_bd weui_cell_primary">
                        {{modelData.RBContent|html}}
                    </div>
                </div>
            </div>
        </div>
        <div class="weui_cells_title">其他信息</div>
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    {{modelData.RBWCQK|html}}
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">抄送人</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    {{ComFunJS.convusers(modelData.ChaoSongUser)}}
                </div>
            </div>
        </div>
        <div class="weui_cells_title">图片上传</div>
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <div class="viewimg">{{modelData.Files}}</div>
                </div>
            </div>
        </div>
    </div>
</div>




<script>

    var tempmodel = avalon.define({
        $id: "MGZBG",
        name: "工作报告",
        ColumnData: [],
        pageType: "edit",
        tpData: [],
        plData: [],
        plcount: 0,
        dataid: "",
        wximg: "",
        modelData: { "RBDate": "", "RBContent": "", "LeiBie": "", "RBWCQK": "", "Files": "", "ChaoSongUser": "" },
        inittemp: function (strId) {

            $.getJSON('/API/VIEWAPI.ashx?Action=XTGL_GETZIDIANLIST', { P1: 6 }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    tempmodel.ColumnData = resultData.Result;
                    if (tempmodel.ColumnData.size() > 0 && !tempmodel.modelData.LeiBie) {
                        tempmodel.modelData.LeiBie = resultData.Result[0].ID;
                    }
                }
            })


            if (strId) {

                tempmodel.dataid = strId;
                //编辑加载数据
                $.getJSON('/API/VIEWAPI.ashx?Action=GZBG_GETGZBGMODEL', { P1: strId }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        tempmodel.modelData = resultData.Result;

                        tempmodel.plData = resultData.Result1;
                        tempmodel.plcount = resultData.Result1.length;
                        tempmodel.tpData = resultData.Result2;
                        ComFunJS.uploadimgnew(tempmodel.tpData);
                        ComFunJS.viewimg(tempmodel.tpData);
                        if (tempmodel.modelData.RBDate && tempmodel.modelData.RBDate.length > 10) {
                            tempmodel.modelData.RBDate = tempmodel.modelData.RBDate.substring(0, 10);

                            $("#appDate").calendar({
                                value: [tempmodel.modelData.RBDate]
                            });
                        }


                        setTimeout("ComFunJS.initForm()", 500)
                    }
                })
            } else {
                $("#appDate").calendar({
                    value: [ComFunJS.getnowdate("yyyy-mm-dd")]
                });
                tempmodel.modelData.RBDate = ComFunJS.getnowdate("yyyy-mm-dd");
                ComFunJS.initForm();
                ComFunJS.uploadimgnew();
            }
        },//初始化
        SaveData: function (callback) {
            if (!tempmodel.modelData.LeiBie) {
                top.ComFunJS.winwarning("请选择工作报告类型");
                return;
            }
            $("#imglist .tpli").each(function () {
                if ($(this).hasClass("wximg")) { //微信上传未处理的图片
                    if (tempmodel.wximg) {
                        tempmodel.wximg += ",";
                    }
                    tempmodel.wximg += $(this).attr("itemid");

                }
            })
            $.getJSON("/API/VIEWAPI.ashx?ACTION=GZBG_ADDGZBG&r=" + Math.random(), { P1: JSON.stringify(tempmodel.modelData.$model), P2: tempmodel.wximg }, function (result) {
                return callback.call(this, result);
            });
        },
        Complate: function () {
            window.location.href = "/View_Mobile/UI/UI_GZBG_LIST.html?r=" + Math.random();
        },
        pl: function () {

            ComFunJS.showCommentNew(function (result) {
                $.getJSON('/API/VIEWAPI.ashx?Action=XTGL_ADDCOMENT&r=' + Math.random(), { "P1": result.comment, "Points": result.point, "MsgType": "GZBG", "MsgLYID": tempmodel.dataid }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        tempmodel.plData.push(resultData.Result);
                        tempmodel.plcount = tempmodel.plcount + 1;
                        $.toast("评论成功");
                    }
                    else {
                        $.toast("评论失败");
                    }
                })

            }, true);
        },
        Complate: function () {
            window.location.href = "/View_Mobile/UI/UI_GZBG_LIST.html?r=" + Math.random();
        }
    });//# sourceURL=MGZBG.js;
    tempmodel.modelData.$watch("RBContent", function (a, b) {
        if (!pmodel.DataID) {
            localStorage.setItem(pmodel.FormCode, JSON.stringify(tempmodel.modelData.$model));
        }
    })
    function pf(str) {
        if (str) {
            var html = '<div></div>';
            var html1 = $(html).raty({
                readOnly: true,
                score: str * 1 / 20
            }).html();
            return html1;
        }
        else {
            return '';
        }
    }
</script>